package com.hxw;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@PropertySource(value = {"classpath:config/b.properties","classpath:a.properties"})
@Controller
@SpringBootApplication
public class SpringbootCommonApplication {

    private String helloBean;

    @Value("${afile}")
    private String fileName;

    //通过构造器进行依赖注入
    @Autowired
    public SpringbootCommonApplication(String helloBean){
        this.helloBean = helloBean;
    }

    @GetMapping(value = "/hello")
    @ResponseBody
    public String hello(){
        return helloBean;
    }

    @GetMapping(value = "/hello1")
    @ResponseBody
    public String hello1(){
        return fileName;
    }

	public static void main(String[] args) {
		SpringApplication.run(SpringbootCommonApplication.class, args);
	}
}
